I was in the process of writing a routine to display a "splash screen" when Janet threw down the gauntlet with her Spring Fling Challenge.  It sounded like something I could easily use my splash screen for, so I decided to submit this code.  There are no advanced procedures used and any beginner should have success with this code, or small snippets to use in their own projects.

[code]
'Spring Fling Demo
'Written by Welo, 022305

NOMAINWIN

WindowWidth=DisplayWidth
WindowHeight=DisplayHeight

DIM frame$(16)  'Array to hold image name
    FOR k=1 to 16
        READ temp$  'Arrays loaded from DATA must first be READ to a temp variable.
        frame$(k)=temp$
    NEXT k

LOADBMP "stpats", "stpats_01.bmp"
LOADBMP "splash", "splash.bmp"
LOADBMP "img1", "lepr1.bmp"
LOADBMP "img4", "lepr4.bmp"
LOADBMP "img7", "lepr7.bmp"
LOADBMP "img10", "lepr10.bmp"
OPEN "Happy Saint Patrick's Day!" for graphics_nsb as #main
PRINT #main, "trapclose [closeMe]"

FOR replay=1 to 3  'Run 3 cycles of the demo, then END.
    PLAYWAVE "irishjig.wav", asynch
    x=1400  'Start point to print text (off-screen, right)
    y1=300  'start point to print happy shamrock
    flag=2  'value to move happy shamrock each time
[showBMP]
    print #main, "drawbmp splash 80 225"
    print #main, "flush"

    DO UNTIL x<-1600  'DO UNTIL text is off-screen left.
    y1=y1+flag
    cntr=cntr+1  'The counter to identify image to be displayed.
    print #main, "discard"
    print #main, "drawbmp img"+frame$(cntr)+" 420 150"
    print #main, "drawbmp stpats 800 ";y1
    print #main, "font times_new_roman 48 italic"
    print #main, "color GREEN"
    x=x-4  'Move printed text 4 pixels left each time through the loop.
    print #main, "place "; x; " 650"
    print #main, "\This St. Patrick's message presented using Just BASIC! "
    'set the limits up/down for happy shamrock
    IF y1=280 OR y1=320 THEN flag=(-1*flag)  'change direction of the shamrock
    IF cntr=16 THEN cntr=0  'Reset counter to display images
    TIMER 25, [done] : WAIT
    [done]
    TIMER 0
    LOOP  'Go back to DO UNTIL
NEXT replay

[closeMe]
    UNLOADBMP "splash"
    UNLOADBMP "stpats"
    UNLOADBMP "img1"
    UNLOADBMP "img4"
    UNLOADBMP "img7"
    UNLOADBMP "img10"
    PLAYWAVE ""
    CLOSE #main
    END

DATA "1", "1", "1", "1"
DATA "4", "4", "4", "4"
DATA "7", "7", "7", "7"
DATA "10", "10", "10", "10"

[/code]

Please excuse the irishjig.wav, the quality is pretty poor but it was the only one I had available.  That fellow doing the jig was enticed from his home on the Internet by offering him a pint of stout, but needed a few modifications since the file was in GIF format and had to be converted to BMP.

Now that I had all the supporting files, I could begin to work on the code.  Since I was working on a splash screen, I knew I wanted a window to cover the entire monitor.  Because it would have images and more, I chose to open a window for graphics, without scroll bars, and treat the entire window as a graphics box.  The code was pretty simple...

[code]
WindowWidth=DisplayWidth
WindowHeight=DisplayHeight
GRAPHICBOX #main.gbx, 0, 0, DisplayWidth, DisplayHeight
OPEN "Happy Saint Patrick's Day!" for graphics_nsb as #main
[/code]

Next I put in the scrolling text, beginning by printing off-screen right (x=1400) and moving the text 4 pixels left with each pass through the loop.  To erase what had been printed before, the text string has two spaces at the end.

Then I put in the irishjig.wav.  Okay, I'll admit it sounds pretty awful if you listen to it over and over, so just click the X in the upper-right corner any time to exit.  The music was synchronized (approximately) by adjusting the scroll value of x, between -1 and -5.  I did not choose to place a WAIT statement before [closeMe] because I want the program to close when the text had scrolled completely off the left side of the screen, x<-1600, and fairly close to the end of the WAV.

Now for the images.  The JB splash image was fudged up from the JB home page.  I hope Shoptalk will not be upset by any copyright violations, I just love the really cool colors!  The limits for the little bouncing shamrock are set with y1, and the flag is reset by flag=(-1*flag) each time the image is printed at the upper or lower limit.  (Thanks to Stephen Pendl for this cool trick!)

The leprechaun gave me the most difficulty because the GIF image consisted of only 4 frames.  I converted these to BMP images, but with the TIMER controlling the interval of the DO/LOOP, printing text and a new leprechaun with each iteration, the animation made it appear he was dancing to a SALSA rhythm.  (A very HOT SALSA!)  To make the animation slower, I created 3 copies of each frame and displayed them in sequence, which worked fine, but now I had 16 BMP images of around 180KB each, which I find unacceptable.  The trick would be to display 4 images in the same amount of time as 16 images.

I tried several methods to slow down printing the leprechaun images, without slowing down printing of the scrolling text and shamrock.  I finally solved the problem by displaying frame1 four times in succession, then displaying frame2 four times, etc.  Visually, the animation was acceptable and required only 4 images rather than 16.  Each time the frame counter equals 16, it is reset to 0 and the animation begins again with the first frame.

Array frame$() holds the name of the image, NOT the actual image.  The name of the image is concatenated with the statement "drawbmp img"+frame$(cntr)+" 420 150" to issue a PRINT statement to the program.  With each pass through the DO/LOOP, frame$() is printed, 4 times before printing the next image.

Initially, I had some difficulty with page file usage when running this code, especially if I wanted to run through the complete cycle more than once.  Doing so caused the page file usage to continue increasing until the program crashed.  With a nudge in the right direction from BJ Moore, the JB splash logo and FLUSH commands were moved outside the DO/LOOP because it was the only image needed to 'stick' to the display.  All the other images were redrawn with each pass through the loop.  Now the page file usage remains absolutely flat and we do 3 replays before getting rid of that annoying jig.

I considered adding more images, which is the reason for the variable y1 to set the limits of the shamrock.  With more bouncing images, I would need y2, etc.  Eventually I decided 'enough is enough!'  Don't clutter it up anymore.  Hey, it was fun, and look at everything I've learned for the next splash-screen I want to create!
